<?php

namespace App\Middlewares;
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

/**
 * 身份认证中间件
 */

class AuthMiddleware extends BaseMiddleware {

	public function __invoke(Request $request, Response $response, $next) {

		if ($_SESSION["UserName"] == null) {
			return $response -> withRedirect($this -> container -> router -> pathFor('Login'));
		}

		$response = $next($request, $response);
		return $response;
	}

}
